package itheima.com.stream2;

import itheima.com.stream.Student;

import java.util.ArrayList;
import java.util.List;

public class Test1 {
    public static void main(String[] args) {
        //准备测试数据：
        List<Student> students = new ArrayList<>();
        students.add(new Student("小王", 18, 66.0));
        students.add(new Student("小张", 17, 99.0));
        students.add(new Student("小李", 26, 20.0));
        students.add(new Student("小赵", 16, 77.0));
        students.add(new Student("小刘", 19, 18.0));
        students.add(new Student("小李", 26, 20.0));
        students.stream()
                .filter(student -> student.getScore() > 60.0)
                .sorted((s1,s2)->Double .compare(s2.getScore(),s1.getScore()))
                .forEach(System.out::println);
        students.stream()
                .filter(student -> student.getAge()>18)
                .filter(student -> student.getAge()<=25)
                .sorted((s1,s2)->s1.getAge()-s2.getAge())
                .forEach(System.out::println);
        System.out.println("===============]");

        students.stream()
                .sorted((s1,s2)->Double .compare(s2.getScore(),s1.getScore()))
                .limit(3)
                .forEach(System.out::println);
        System.out.println("-------------------------");
        students.stream()
                .filter(student -> student.getAge()>18)
                .distinct()
                .forEach(System.out::println);

        }
    }

